@extends("web.layout.common")
@section("title")
     二维码
@endsection
@section('style')
    <style>
        body{height: 100%;}
    </style>
@endsection
@section('content')
    <link href="{{asset('css/web/login.css')}}" rel="stylesheet">
    <div class="qrcode_box">
        <img id="img" src="{{$path}}" height="305">
        <div class="qrcode_num" >距离二维码失效还有<span id="text">120</span>秒</div>
    </div>
@endsection
@section('script')
<script>
    var num = 120;
    function token(){
        num--
        $("#text").text(num);
        if(num == 0){
            $(".qrcode_num").text("二维码已失效，请刷新页面");
            $("#img").attr({"src":"/images/error.png"})
            clearInterval(show);
        }
        $.post("{{route('web.qrcode')}}",
            {
                token:'{{$token}}',
                _token:'{{csrf_token()}}'
            }
        ,function(data){
           console.log(data)
                if(data == 2){
                    window.location.href = '{{route("index")}}';
                }
        });
    }
    var show = setInterval(function(){
        token();
    }, 1000);
</script>
@endsection


